package cn.edu.neu.lab603.cloudeval.experiment

import cn.edu.neu.lab603.cloudeval.strategy.VMMigrationStrategy
import cn.edu.neu.lab603.cloudeval.strategy.policy._
import org.scalatest.FunSuite

/** MAD 系列调度算法的实验。
  *
  * Created by yfwz100 on 2016/11/11.
  */
class MADExperiments extends FunSuite {

  test("MAD-MC") {
    ExperimentSetup
      .setMigrationStrategy { setup =>
        val hostSelectionPolicy = new HostSelectionPolicyMAD(
          setup.utilizationMonitor,
          new HostSelectionPolicyStaticThreshold(1.0)
        )
        new VMMigrationStrategy(
          hostSelectionPolicy.getReallocationTimePolicy(60),
          hostSelectionPolicy,
          new VMSelectionPolicyMaximumCorrelation
        )
      }
      .run()
  }

  test("MAD-MU") {
    ExperimentSetup
      .setMigrationStrategy { setup =>
        val hostSelectionPolicy = new HostSelectionPolicyMAD(
          setup.utilizationMonitor,
          new HostSelectionPolicyStaticThreshold(1.0)
        )
        new VMMigrationStrategy(
          hostSelectionPolicy.getReallocationTimePolicy(60),
          hostSelectionPolicy,
          new VMSelectionPolicyMinimumUtilization
        )
      }
      .run()
  }

  test("MAD-MMT") {
    ExperimentSetup
      .setMigrationStrategy { setup =>
        val hostSelectionPolicy = new HostSelectionPolicyMAD(
          setup.utilizationMonitor,
          new HostSelectionPolicyStaticThreshold(1.0)
        )
        new VMMigrationStrategy(
          hostSelectionPolicy.getReallocationTimePolicy(60),
          hostSelectionPolicy,
          new VMSelectionPolicyMinimumMigrationTime
        )
      }
      .run()
  }

  test("MAD-RS") {
    ExperimentSetup
      .setMigrationStrategy { setup =>
        val hostSelectionPolicy = new HostSelectionPolicyMAD(
          setup.utilizationMonitor,
          new HostSelectionPolicyStaticThreshold(1.0)
        )
        new VMMigrationStrategy(
          hostSelectionPolicy.getReallocationTimePolicy(60),
          hostSelectionPolicy,
          new VMSelectionPolicyRandomSelection
        )
      }
      .run()
  }

}
